<template>
	<div class="w750">
		<!-- 意见反馈 -->
		<div class="new-share">
			<!-- <div class="share-category">
				<div class="fl">问题类型</div>
				<div class="fr">
					<span class="choose-item">商品相关</span>
					<em class="arrow"><img src="../../assets/images/arrow.png" alt=""></em>
				</div>
			</div> -->
			<div class="share-txt">
				<div class="txt-item"><textarea placeholder="请详细描述您的问题或建议，我们会及时跟进。（建议字数在250字以内）" v-model="txt"></textarea></div>
			</div>
			<div class="share-txt">
				<div class="txt-item"><input type="text" placeholder="请填写手机号，方便我们与您联系" v-model="phone"></div>
			</div>
			<!-- <div class="share-img">
				<a href="#" class="add-img"><img src="img/activity01.jpg" alt=""><i class="del-img">×</i></a>
				<a href="#" class="add-img"><img src="img/activity02.jpg" alt=""><i class="del-img">×</i></a>
				<a href="#" class="add-img"><img src="img/activity03.jpg" alt=""><i class="del-img">×</i></a>
				<a href="#" class="add-img"><em class="add-txt">+</em></a>
				<p class="add-img-tip">温馨提示：最多添加4张图片</p>
			</div> -->
			<div class="b-btn" @click="submit" :class="themes.theme"><span class="btn-r">提交反馈</span></div>
		</div>
		<!-- /意见反馈 -->
		<!-- 选择类型 -->
		<!-- <van-popup v-model="sexshow" position='bottom' >
			<van-picker
			  show-toolbar
			  :columns="columns"
			  @cancel="onCancel"
			  @confirm="onConfirm"
			/>
		</van-popup> -->
		<!-- /选择类型 -->
	</div>
</template>

<script>
 import { Feedback } from "api/feedback";
 import {mapState} from 'vuex'
 export default {
   data () {
     return {
			 
     	feedback: '',  //意见反馈
     	txt: '',  //内容
     	phone: '',  //电话
     	photoServer: this.$imgUrlHead,  //图片
      	// columns: ['商品相关', '物流状况', '客户服务', '优惠活动', '功能异常', '产品建议', '其他'],
     }
   },
   mounted() {
     let that = this

	},
	methods: {
    goback() {
      this.$router.back();
      this.$router.isBack = true;
    },
	    //提交反馈意见
		submit() {
			if(!this.txt) {
	          this.$toast('请输入您的反馈意见')
	          return
	        }
	        if( this.txt.length > 250 ) {
	          this.$toast('超过字数限制')
	          return
	        }
			if(!this.phone) {
	          this.$toast('请输入您的手机号码')
	          return
	        }else {
	          if(this.phoneRight == false) {
	            this.$toast("请输入正确的手机号码");
	            return;
	          }
	        }
	        Feedback({content: this.txt, mobile: this.phone}).then(res => {
				if(res.status == 1){
					this.feedback = res.result
					this.$toast("提交成功")
	            	this.$router.push('/my')
				}else{
					this.$toast(res.msg)
				}
			})
		}
	},
   	computed: {
	     ...mapState(['themes']),
		//检测手机号码是否正确
		phoneRight() {
		return /^1[0-9][0-9]{9}$/.test(this.phone);
		}
	},
 };
</script>

<style src="../../assets/css/new-share.css" scoped></style>
<style scoped>
	.new-share .share-txt textarea {
		height: 130px;
	}
</style>
